package abstractEntities;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator;

import entities.Coursestudent;
import entities.Lessonstudent;
import entities.Mastercoach;
import entities.User;

/**
 * AbstractStudent entity provides the base persistence definition of the
 * Student entity. @author MyEclipse Persistence Tools
 */
@MappedSuperclass
public abstract class AbstractStudent implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 5289300196439463194L;
	private Integer idStudent;
	private Mastercoach mastercoach;
	private User user;
	private Date heldDate;
	private Set<Coursestudent> coursestudents = new HashSet<Coursestudent>(0);
	private Set<Lessonstudent> lessonstudents = new HashSet<Lessonstudent>(0);

	// Constructors

	/** default constructor */
	public AbstractStudent() {
	}

	/** minimal constructor */
	public AbstractStudent(Mastercoach mastercoach, User user, Date heldDate) {
		this.mastercoach = mastercoach;
		this.user = user;
		this.heldDate = heldDate;
	}

	/** full constructor */
	public AbstractStudent(Mastercoach mastercoach, User user, Date heldDate,
			Set<Coursestudent> coursestudents, Set<Lessonstudent> lessonstudents) {
		this.mastercoach = mastercoach;
		this.user = user;
		this.heldDate = heldDate;
		this.coursestudents = coursestudents;
		this.lessonstudents = lessonstudents;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "idStudent", unique = true, nullable = false)
	public Integer getIdStudent() {
		return this.idStudent;
	}

	public void setIdStudent(Integer idStudent) {
		this.idStudent = idStudent;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idMaster", nullable = false)
	public Mastercoach getMastercoach() {
		return this.mastercoach;
	}

	public void setMastercoach(Mastercoach mastercoach) {
		this.mastercoach = mastercoach;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idUser", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "heldDate", nullable = false, length = 10)
	public Date getHeldDate() {
		return this.heldDate;
	}

	public void setHeldDate(Date heldDate) {
		this.heldDate = heldDate;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "student")
	public Set<Coursestudent> getCoursestudents() {
		return this.coursestudents;
	}

	public void setCoursestudents(Set<Coursestudent> coursestudents) {
		this.coursestudents = coursestudents;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "student")
	public Set<Lessonstudent> getLessonstudents() {
		return this.lessonstudents;
	}

	public void setLessonstudents(Set<Lessonstudent> lessonstudents) {
		this.lessonstudents = lessonstudents;
	}

}